import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ActionSheetController, AlertController, ModalController } from 'ionic-angular';

/**
 * Generated class for the MinePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-mine',
  templateUrl: 'mine.html',
})
export class MinePage {
  
  isLogin:boolean = false;
  constructor(public navCtrl: NavController, public navParams: NavParams, public actionSheetCtrl: ActionSheetController,public alertCtrl: AlertController, public modalCtrl: ModalController) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad MinePage');
  }

  //登录
  login() {
    // this.isLogin = !this.isLogin;
    let modal = this.modalCtrl.create("ModalLoginPage");
    modal.onDidDismiss(data=>{
      console.log("关闭登录弹框==="+data);
    })
    modal.present();
  }
  //提现中心
  tixian_zx() {
    this.navCtrl.push('TixianPage');
  }

  //提现记录
  tixian_jl() {

  }
  //邀请好友
  inviteFriend() {

  }

  presentActionSheet() {
    let actionSheet = this.actionSheetCtrl.create({
      title:'更换头像',
      cssClass:'headChoice', //cssClass:  是关键， 是自定义的这个弹窗的class名，可以根据这个class名对弹窗进行样式的自定义，这个class名的使用一定要在app文件夹里面的app.scss里面进行修改，不然不起作用。buttons里面的icon是添加ionic自带的图标的
      buttons:[{
        text:'拍照',
        icon:'ios-arrow-forward',
        role:'destructive',
        handler: () => {
          console.log('Destructive clicked');
          // this.cameraService.clickCamera();
        }
      },{
        text: '从相册选择',
        icon: 'ios-arrow-forward',
        handler: () => {
          console.log('Archive clicked');
          // this.cameraService.clickImagePicker();
        }
      },{
        text: '取消',
        role: 'cancel',
        handler: () => {
          console.log('Cancel clicked');
        }
      }]
    });
    actionSheet.present();
  }

  showCheckbox() {
    let alert = this.alertCtrl.create({
      title:'项目分类列表',
      cssClass:'',  //projectList
    });
 
    alert.addInput({
      type: 'checkbox',
      label: '工程勘察',
      value: 'value1'
    });

    alert.addInput({
      type: 'checkbox',
      label: '工程监理',
      value: 'value2'
    });


    alert.addButton('取消');
    alert.addButton({
      text: '关注',
      handler: data => {
        console.log('Checkbox data:', data);
//      this.testCheckboxOpen = false;
//        this.testCheckboxResult = data;
      }
    });
    alert.present();
  }
}

